package com.rainy.micservice.feignclient.service;

import com.rainy.micservice.feignclient.DemoClient;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Date;

//import feign.hystrix.FallbackFactory;

/**
 * @author: guoxiaolin
 * @date : 2019-03-15
 *
 * @说明: 不要忘记添加熔断响应,可作为熔断异常日志记录操作
 * 这个熔断是熔断provider,,zuul项目中的熔断配置才是熔断consumer的;
 * 也就是说:
 * provider异常,consumer的熔断配置才会生效
 * consumer异常,zuul的熔断配置就会生效
 */
@Component
public class DemoClientFallbackFactory implements FallbackFactory<DemoClient> {


    @Override
    public DemoClient create(Throwable throwable) {
        return new DemoClient() {
            @Override
            public String home() {
                return new Date().getTime() + " 请求日志: index/home 调用失败。";
            }
        };
    }
}